package com.app;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.app.adapter.MenuAdapter;

public class MainActivity extends AppCompatActivity {

    private ListView menuListView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initEvent();
    }

    private void initView(){
        String[] menuArray = new String[]{"用户列表","校园新闻"};
        menuListView = (ListView) findViewById(R.id.menu_listview);
        MenuAdapter menuAdapter = new MenuAdapter(MainActivity.this,menuArray);
        menuListView.setAdapter(menuAdapter);

    }

    private void initEvent(){
        menuListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent=null;
                switch (position){
                    case 0:
                        intent = new Intent(MainActivity.this,ClassmateListActivity.class);
                        break;
                    case 1:
                        break;
                }
                startActivity(intent);
            }
        });
    }

    private void iinitData(){

    }
}